var bbk = {
	user: '',
	icons: ['heart', 'light', 'time', 'at', 'mike', 'key', 'gift', 'wifi', 'rate', 'solid',
		'username', 'snowflake', 'note', 'senior', 'flag', 'theme', 'notice', 'website', 'console',
		'face-surprised', 'template-1', 'praise', 'camera', 'camera-fill', 'rmb', 'diamond', 'fire', 'location',
		'read', 'face-smile', 'component', 'user', 'find-fill', 'headset', 'speaker', 'picture', 'share',
		'dialogue', 'date', 'water', 'carousel', 'tree', 'chart', 'engine', 'file', 'friends', 'log', 'chat',
		'star', 'fill', 'circle', 'rss', 'email', 'service', 'addition', 'rate', 'rate-solid', 'vercode',
		'cellphone', 'password', 'home', 'cart-simple', 'cart', 'play', 'pause', 'video', 'voice', 'link',
		'tabs', 'radio', 'form', 'layer', 'prev-circle', 'util', 'table', 'chart-screen', 'add-circle', 'about',
		'up', 'down', 'left', 'right', 'search', 'set-fill', 'group', 'reply-fill', 'menu-fill', 'release',
		'ok', 'star-fill', 'ok-circle', 'add-circle-fine'
	],
	//是否为空
	isEmpty: function(str) {
		if (str == undefined || str == 'undefined' || str == null || str == "null" || str == "NULL") {
			return true;
		}
		if (typeof str === "function") {
			return false;
		}
		if (typeof str === "string") {
			str = str.replace(" ", "");
			str = str.trim();
		}
		return str.length == 0;
	},
	setUser: function(user) {
		//save
		this.user = user;
		localStorage.BBK_USER = JSON.stringify(user);
	},
	initIconId: function() {
		if (!bbk.isEmpty(bbk.getUser())) {
			let iconId = bbk.getUser().id - 100000;
			if (iconId >= this.icons.length * this.icons.length) {
				return;
			}
			let iconIndex1 = Math.trunc(iconId / this.icons.length);
			let iconIndex2 = iconId % this.icons.length;
			$('#icon-id-box-1').html('<i class="layui-icon layui-icon-' + bbk.icons[iconIndex1] + '"></i>');
			$('#icon-id-box-2').html('<i class="layui-icon layui-icon-' + bbk.icons[iconIndex2] + '"></i>');
		}
	},
	isBuyer: function() {
		if (this.isEmpty(localStorage.BBK_USER)) {
			return true;
		}
		let user = JSON.parse(localStorage.BBK_USER);
		return user.buyerCode == 1;
	},
	isAgenter: function() {
		if (this.isEmpty(localStorage.BBK_USER)) {
			return false;
		}
		let user = JSON.parse(localStorage.BBK_USER);
		return user.buyerCode == 2;
	},
	isAdviser: function() {
		if (this.isEmpty(localStorage.BBK_USER)) {
			return false;
		}
		let user = JSON.parse(localStorage.BBK_USER);
		return user.buyerCode == 0;
	},
	getUser: function() {
		if (!this.isEmpty(this.user)) {
			return this.user;
		}
		if (!this.isEmpty(localStorage.BBK_USER)) {
			return JSON.parse(localStorage.BBK_USER);
		}
		return '';
	},
	isDebug: function() {
		// return true;
		let host = window.location.host;
		if (host.indexOf('localhost') > -1) {
			return true;
		}
		if (host.indexOf('127.0.0.1') > -1) {
			return true;
		}
		return false;
	},
	$: function(id) {
		return document.getElementById(id);
	},

	getVal: function(id) {
		return this.trim(this.$(id).value);
	},
	reload: function(s) {
		setTimeout(function() {
			window.location.reload();
		}, 1000 * s);
	},
	//获得扩展名
	getExName: function(name) {
		let arr = name.split('.');
		if (arr.length > 1) {
			return arr[arr.length - 1].toLowerCase();
		}
	},
	//获得随机数
	getRandomStr: function(maxSize) {
		var str = '';
		var char = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
			's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
		];
		for (var i = 0; i < maxSize; i++) {
			str += char[parseInt(Math.random() * 36)];
		}
		return str;
	},
	timStamp: function() { //10位
		return parseInt(new Date() / 1000);
	},
	//获得两位数字
	getTwo: function(num) {
		if (num >= 1 && num <= 9) {
			return "0" + num;
		}
		return num;
	},
	getTwo2: function(str) {
		if (str.length == 1) {
			return '0' + str;
		}
		return str;
	},
	//获得日期 eg:20220226
	getDate: function() {
		var date = new Date();
		return date.getFullYear() + bbk.getTwo(date.getMonth() + 1) + bbk.getTwo(date.getDate());
	},
	//返回秒
	getDuration(start, end) {
		return new Date(end).getTime() - new Date(start).getTime();
	},
	getDurationDay(end) {
		let time = new Date(end).getTime() - new Date().getTime();
		return parseInt(time / 1000 / 60 / 60 / 24);
	},
	addDay(start, day) {
		let timestamp = new Date(start).getTime(); //当前的时间戳
		timestamp = timestamp + day * 24 * 60 * 60 * 1000;
		//格式化时间获取年月日
		var dateAfter = new Date(timestamp);
		return dateAfter.getFullYear() + '-' + (dateAfter.getMonth() + 1) + '-' + dateAfter
			.getDate() + ' ' + dateAfter.getHours() + ':' + dateAfter.getMinutes() + ':' + dateAfter.getSeconds();
	},
	addTime(day) {
		let timestamp = new Date().getTime(); //当前的时间戳
		timestamp = timestamp + day * 24 * 60 * 60 * 1000;
		//格式化时间获取年月日
		var dateAfter = new Date(timestamp);
		return dateAfter.getFullYear() + '-' + (dateAfter.getMonth() + 1) + '-' + dateAfter
			.getDate() + ' ' + dateAfter.getHours() + ':' + dateAfter.getMinutes() + ':' + dateAfter.getSeconds();
	},
	//深克隆
	clone: function(obj) {
		let str = JSON.stringify(obj);
		return JSON.parse(str);
	},
	//qr={text:'',width:'',hegith:''} 不含px
	getQrSrc: function(qr) {
		let target = document.createElement('div');
		var qrcode = new QRCode(target, qr);
		return target.childNodes[0].toDataURL();
	},
	ajax: function(ajaxData) {
		var myAjax = {
			success: ajaxData.success,
			error: ajaxData.error,
			warn: ajaxData.warn
		};
		ajaxData.success = function(res) {
			if (bbk.isDebug()) {
				console.info('received:', res);
			}
			if (typeof(res) == 'string') {
				res = JSON.parse(res);
			}
			switch (res.code) {
				case 0:
					if (bbk.isEmpty(myAjax.success) || (!bbk.isEmpty(myAjax.success) && myAjax.success(
							res) != false)) {
						Msger.info(res.msg); //服务返回的成功信息
					}
					break;
				default:
					if (bbk.isEmpty(myAjax.error) || (!bbk.isEmpty(myAjax.error) && myAjax.error(
							res) != false)) {

						switch (res.code) {
							case Cons.ERROR_CODE.NOT_LOGIN: //账户未登录
								Login.login();
								break;
							case Cons.ERROR_CODE.NEED_SCAN: //需要扫码认证
								if (bbk.isEmpty(res.msg)) {
									Login.scan('微信扫一扫认证');
								} else {
									Login.scan(res.msg);
								}
								break;
							case Cons.ERROR_CODE.NEED_VIP: //需要扫码认证
								Msger.isSure(res.msg, function() {
									window.open('/html/helper/viper.html', '_blank');
								})
								break;
							default:
								Msger.error(res.msg); //服务返回的报错信息,没有error回调
						}
					}
			}
		}
		ajaxData.error = function(obj) {
			Msger.error("网络出现异常！");
		}
		if (bbk.isEmpty(ajaxData.method)) {
			ajaxData.method = "POST";
		}
		layui.$.ajax(ajaxData);
		if (bbk.isDebug()) {
			console.info('send:', JSON.stringify(ajaxData));
		}
	},
	getUrlVal: function(label) {
		var url = window.location.search;
		if (this.isEmpty(url)) {
			return "";
		}
		url = url.replace("?", "");
		var arr = url.split("&");
		for (var i = 0; i < arr.length; i++) {
			var aa = arr[i].split("=");
			if (aa.length == 2) {
				if (aa[0] == label) {
					return aa[1]
				}
			}
		}
		return '';
	},
	setUrlVal:function(label,val){
		var url = window.location.search;
		url = url.replace("?", "");
		var vals = url.split("&");
		let s='';
		for (var i = 0; i < vals.length; i++) {
			let one=vals[i].split('=');
			if(one.length==2){
				if(label!=one[0]){
					s+=one[0]+'='+one[1]+'&'
				}
			}
		}
		if(!this.isEmpty(val)){
			s+=label+'='+val
		}
		window.location.search=s;
	},
	trim: function(str) {
		if (this.isEmpty(str)) {
			return '';
		}
		return str.trim();
	},
	//获得滚动轴离底部距离
	getScrollBottom: function() {
		// 变量 scrollHeight 是滚动条的总高度
		let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight
		// 变量 windowHeight 是可视区的高度
		let windowHeight = document.documentElement.clientHeight || document.body.clientHeight
		// 变量scrollTop为当前页面的滚动条纵坐标位置
		let scrollTop = document.documentElement.scrollTop || document.body.scrollTop
		// 滚动条到底部得距离 = 滚动条的总高度 - 可视区的高度 - 当前页面的滚动条纵坐标位置
		var scrollBottom = scrollHeight - windowHeight - scrollTop
		return scrollBottom;
	},
	copy: function(text) {
		var oInput = document.createElement('textarea');
		oInput.value = text;
		document.body.appendChild(oInput);
		oInput.select(); // 选择对象
		document.execCommand("Copy"); // 执行浏览器复制命令
		oInput.style.display = 'none';
		Msger.info('复制成功');
	},
	getPrice: function(str) {
		if (this.isEmpty(str)) {
			return 0;
		}
		let price = this.doGetPrice(str);
		if (price + '' == 'NaN') {
			return 0
		}
		return price;
	},
	doGetPrice: function(str) {
		try {
			if (str.indexOf('元') > -1) {
				return parseInt(bbk.getFloat(str));
			}
			if (str.indexOf('万') > -1) {
				return parseInt(parseFloat(bbk.getFloat(str)) * 10000);
			}
			if (str.indexOf('W') > -1) {
				return parseInt(parseFloat(bbk.getFloat(str)) * 10000);
			}
			if (str.indexOf('w') > -1) {
				return parseInt(parseFloat(bbk.getFloat(str)) * 10000);
			}
			if (str.indexOf('千') > -1) {
				return parseInt(parseFloat(bbk.getFloat(str)) * 1000);
			}
			if (str.indexOf('K') > -1) {
				return parseInt(parseFloat(bbk.getFloat(str)) * 1000);
			}
			if (str.indexOf('k') > -1) {
				return parseInt(parseFloat(bbk.getFloat(str)) * 1000);
			}
			return parseInt(bbk.getFloat(str));
		} catch (e) {
			console.error(e);
			Msger.error('系统无法识别该价格:' + str);
		}
	},
	getFloat: function(str) {
		str = str.replace(/[\u4e00-\u9fa5A-Z a-z\t]/g, '');
		return str;
	},
	isWxPc: function() {
		if (layui.device().weixin && !layui.device().mobile) {
			return true;
		}
		return false;
	},
	down: function(url) {
		var f = document.createElement("form");
		document.body.appendChild(f);
		var i = document.createElement("input");
		i.type = "hidden";
		f.appendChild(i);
		i.value = "5";
		i.name = "price";
		f.action = url; //下载的url 地址 
		f.submit();
	},
	base64toBlob: function(dataURI) {
		var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; // mime类型
		var byteString = atob(dataURI.split(',')[1]); //base64 解码
		var arrayBuffer = new ArrayBuffer(byteString.length); //创建缓冲数组
		var intArray = new Uint8Array(arrayBuffer); //创建视图

		for (var i = 0; i < byteString.length; i++) {
			intArray[i] = byteString.charCodeAt(i);
		}
		return new Blob([intArray], {
			type: mimeString
		});
	},
	copyImg: function(img) {
		try {
			const item = new ClipboardItem({
				'image/png': bbk.base64toBlob(img.src)
			})
			navigator.clipboard.write([item]);
			Msger.info('图片已复制');
		} catch (e) {
			console.warn(e);
		}
	},

}
var Hoster = {
	initLogo: function() {
		let host = location.host.replace('www.', '');
		$('#buyer-logo').attr('src', 'https://color.picer.cdn.biaobiaoku.com/logo/' + host +
			'-logo.png?v=20230828');
		document.querySelector('#favicon').href = 'https://color.picer.cdn.biaobiaoku.com/logo/' + host +
			'-favicon.png?v=20230702-2';
	},
	init: function(callback) {
		this.initLogo();
		let hoster = localStorage.INIT_HOST;
		if (!bbk.isEmpty(hoster)) {
			try {
				hoster = JSON.parse(hoster);
				callback(hoster);
			} catch (e) {
				console.error(e);
			}
		}else{
			//初始hoster
			callback({baseColor:'#3f56e0',name:'加载中'})
		}
		/*let ajax = {
			url: '/buyer-user/init-host',
			data: {
				host: location.host
			},
			success: function(res) {
				localStorage.INIT_HOST = JSON.stringify(res.data);
				callback(res.data);
			}
		}
		bbk.ajax(ajax);*/
	},
	getHoster: function() {
		let hoster = localStorage.INIT_HOST;
		if (!bbk.isEmpty(hoster)) {
			try {
				hoster = JSON.parse(hoster);
				return hoster;
			} catch (e) {
				console.error(e);
			}
		}
		return '';
	},
	getName: function() {
		let hoster = localStorage.INIT_HOST;
		if (!bbk.isEmpty(hoster)) {
			try {
				hoster = JSON.parse(hoster);
				return hoster.name;
			} catch (e) {
				console.error(e);
			}
		}
		return '网站';
	}
}

bh = {
	getHash: function() {
		let hash = bbk.getUrlVal('hash');
		if (!bbk.isEmpty(hash) && hash.length == 32) {
			localStorage.INVITER_HASH = hash;
			return hash;
		}
		return localStorage.INVITER_HASH;
	}
}
//提示信息
Msger = {
	sec: 0,
	info: function(msg) {
		if (!bbk.isEmpty(msg)) {
			layui.layer.msg(msg);
		}
	},
	showBack: function() {
		var obj = bbk.$('msger-back');
		if (bbk.isEmpty(obj)) {
			var div = document.createElement('div');
			div.id = 'msger-back';
			var body = document.querySelector('body');
			body.appendChild(div);
		} else {
			obj.style.display = 'block';
		}
	},
	hideBack: function() {
		var obj = bbk.$('msger-back');
		if (!bbk.isEmpty(obj)) {
			obj.style.display = 'none';
		}
	},
	clock: function() {
		let obj = bbk.$('msger-clock-msg-body');
		if (obj.style.display != 'none') {
			Msger.sec--;
			bbk.$('msger-clock-msg-clock').innerHTML = Msger.sec;
			setTimeout(Msger.clock, 1000)
		}
	},
	clockMsg: function(msg, sec) {
		this.showBack();
		if (bbk.isEmpty(sec)) {
			this.sec = 60;
		}
		this.sec = parseInt(sec);
		var obj = bbk.$('msger-clock-msg-body');
		if (bbk.isEmpty(obj)) {
			var div = document.createElement('div');
			div.id = 'msger-clock-msg-body';
			div.className = 'flex-center';
			div.innerHTML =
				'<div id="msger-clock-msg-box">' +
				'<div>' + msg + '</div>' +
				'<div>预计剩余:<span id="msger-clock-msg-clock"></span></div>' +
				'</div>';
			var body = document.querySelector('body');
			body.appendChild(div);
		} else {
			obj.style.display = 'flex';
			this.showBack();
		}
		this.clock();
	},
	closeClock: function() {
		bbk.$('msger-clock-msg-body').style.display = 'none';
		this.hideBack();
	},
	talk: function(msg) {
		var layer = layui.layer;
		layer.open({
			title: '<i class="layui-icon-dialogue layui-icon"></i>',
			type: 1,
			resize: true,
			content: '<div style="width:350px;height:150px;padding:10px;line-height:30px">' + msg +
				'</div>',
			btn: ['确定']
		});
		//点击空白自动关闭
		setTimeout(function() {
			$('.layui-layer-shade').click(function() {
				layer.close(layer.index);
			})
		}, 300)
	},
	warn: function(msg) {
		var layer = layui.layer;
		layer.open({
			skin: 'smarter',
			title: '<i class="layui-icon layui-icon-face-smile" style="font-size: 30px; color:orange;"></i> ',
			type: 1,
			resize: false,
			content: '<div class="msger-content orange">' + msg + '</div>',
			btn: ['确定'],
		});
		//点击空白自动关闭
		setTimeout(function() {
			$('.layui-layer-shade').click(function() {
				layer.close(layer.index);
			})
		}, 300)
	},
	error: function(msg) {
		var layer = layui.layer;
		layer.open({
			skin: 'smarter',
			title: '<i class="layui-icon layui-icon-face-cry" style="font-size: 30px; color:red;"></i> ',
			type: 1,
			resize: false,
			content: '<div class="msger-content ">' + msg + '</div>',
			btn: ['确定'],
		});
	},
	isSure: function(content, callback) {
		var layer = layui.layer;
		layer.confirm(content, {
			title: '<i class="layui-icon layui-icon-about"></i>'
		}, function(index) {
			if (!bbk.isEmpty(callback)) {
				callback();
			}
			layer.close(index);
		});
	},
	text: function(title, sure, autoClose, holder) {
		var layer = layui.layer;
		holder = bbk.isEmpty(holder) ? "" : holder;
		layer.open({
			skin: 'msger-for-reason',
			title: title,
			type: 1,
			resize: false,
			content: '<textarea id="msger-for-reason-text">' + holder + '</textarea>',
			btn: ['确定'],
			yes: function(index, dom) {
				var text = bbk.$("msger-for-reason-text").value;
				if (bbk.isEmpty(text)) {
					Msger.info("内容不能为空！");
					return;
				}
				sure(text);
				if (autoClose) {
					layer.close(index);
				}
			}
		});
		bbk.$("msger-for-reason-text").focus();
	},
	showTip: function(msg) {
		var obj = bbk.$('static-tip');
		if (bbk.isEmpty(obj)) {
			var div = document.createElement('div');
			div.id = 'static-tip';
			div.innerHTML = msg;
			var body = document.querySelector('body');
			body.appendChild(div);
		} else {
			obj.innerHTML = msg;
		}
	},
}
IoBox = {
	ioBox: '',
	//ioBox={title,content}
	render: function(ioBox) {
		this.ioBox = ioBox;
		var box = $("#io-box");
		if (bbk.isEmpty(box)) {
			box = document.createElement('div');
			box.id = "io-box";
			box.className = 'io-box';
			var inner = '<div id="io-box-title" class="io-box-title"></div>' +
				'<div id="io-box-content" class="io-box-content"></div>' +
				'<div class="io-box-close-box no-cursor" onclick="IoBox.close()"><div class="left">清空</div><i class="layui-icon layui-icon-close"></i></div>'
			box.innerHTML = inner;
			document.body.appendChild(box);

		}
		$("#io-box-title").html(ioBox.title);
		$('#io-box-content').html(ioBox.content);
		$("#io-box").css('display', 'block');
	},
	close: function(silent) {
		try {
			$("#io-box").css('display', 'none');
		} catch (e) {}
		if (!bbk.isEmpty(this.ioBox.close) && !silent) {
			this.ioBox.close();
		}
	}
}
// 元方法
Array.prototype.indexOf = function(val) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == val) return i;
	}
	return -1;
}


Array.prototype.remove = function(val) {
	var index = this.indexOf(val);
	if (index > -1) {
		this.splice(index, 1);
	}
}
Array.prototype.add = function(val) {
	var index = this.indexOf(val);
	if (index == -1) {
		this.push(val);
	}
}
Array.prototype.removeAll = function() {
	while (this.length > 0) {
		this.remove(this[0])
	}
}


//活的按钮
var AcBtn = {
	acBtns: [],
	getAcBtnById: function(id) {
		for (let i = 0; i < this.acBtns.length; i++) {
			if (this.acBtns[i].id == id) {
				return this.acBtns[i];
			}
		}
	},
	add: function(acBtn) {
		let isExist = false;
		for (let i = 0; i < this.acBtns.length; i++) {
			if (acBtn.id == this.acBtns[i].id) {
				this.acBtns[i] = acBtn;
				isExist = true;
			}
		}
		if (!isExist) {
			this.acBtns.push(acBtn);
		}
	},
	isDefault: function(name, acBtn) {
		if (bbk.isEmpty(acBtn.default)) {
			return false;
		}
		for (let i = 0; i < acBtn.default.length; i++) {
			if (name == acBtn.default[i]) {
				return true;
			}
		}
		return false;
	},
	//eg:acBtn={id:"",names:[],click:func,isSingle:false,canClose:true,close:func,addType:true,titles:[],defalt:[]}
	render: function(acBtn) {
		acBtn.data = [];
		//每次渲染都要清空data
		var obj = bbk.$(acBtn.id);
		var html = "";
		for (var i = 0; i < acBtn.names.length; i++) {
			let title = '';
			if (!bbk.isEmpty(acBtn.titles)) {
				title = acBtn.titles[i];
			}
			let addClassName = '';
			if (AcBtn.isDefault(acBtn.names[i], acBtn)) {
				addClassName = 'acbtn-btn-choosed';
				acBtn.data.add(acBtn.names[i]);
			}
			if (acBtn.canClose) {
				html +=
					'<div title="' + title +
					'" onmouseover="AcBtn.onmouseover(this)" onmouseout="AcBtn.onmouseout(this)" class="acbtn-box ' +
					addClassName + '" onclick="AcBtn.click(this)"><span>' +
					acBtn.names[i] +
					'</span><i onclick="AcBtn.close(this,event)" class="layui-icon layui-icon-close acbtn-close-icon"></i></div>';
			} else {
				html += '<div  title="' + title + '" class="acbtn-box  ' + addClassName +
					'" onclick="AcBtn.click(this)"><span>' +
					acBtn.names[i] +
					'</span></div>';
			}

		}
		if (acBtn.addType) {
			obj.innerHTML += html;
		} else {
			obj.innerHTML = html;
		}

		this.add(acBtn);
	},
	click: function(obj) {
		var isChoosed = obj.className.indexOf('acbtn-btn-choosed') > -1;
		var thisText = obj.childNodes[0].innerHTML;
		var id = obj.parentNode.id;
		var acBtn = this.getAcBtnById(id);
		if (acBtn.isSingle) { //单选
			var btns = bbk.$(acBtn.id).childNodes;
			for (var i = 0; i < btns.length; i++) {
				if (!bbk.isEmpty(btns[i].className)) {
					btns[i].className = btns[i].className.replace("acbtn-btn-choosed", "");
				}
			}
			if (isChoosed) {
				acBtn.click('');
			} else {
				obj.className += " acbtn-btn-choosed";
				acBtn.click(thisText);
			}
		} else {
			if (obj.className.indexOf("acbtn-btn-choosed") > 0) {
				obj.className = obj.className.replace("acbtn-btn-choosed", "");
				acBtn.data.remove(thisText);
				acBtn.click(thisText, acBtn.data, false);
			} else {
				obj.className += " acbtn-btn-choosed";
				acBtn.data.push(thisText)
				if (!bbk.isEmpty(acBtn.click)) {
					acBtn.click(thisText, acBtn.data, true);
				}
			}
		}

	},
	close: function(obj, e) {
		let id = obj.parentNode.parentNode.id;
		let thisText = obj.parentNode.childNodes[0].innerHTML;
		var acBtn = this.getAcBtnById(id);
		acBtn.data.remove(thisText);
		obj.parentNode.outerHTML = '';
		if (!bbk.isEmpty(acBtn.close)) {
			acBtn.close(thisText, acBtn.data);
		}
		//阻止冒泡
		e.stopPropagation();
		e.preventDefault();
	},
	//清空选中
	clearChoosed: function(id) {
		var acBtn = this.getAcBtnById(id);
		if (bbk.isEmpty(acBtn)) {
			return;
		}
		acBtn.data.removeAll();
		var btns = bbk.$(id).childNodes;
		for (var i = 0; i < btns.length; i++) {
			if (!bbk.isEmpty(btns[i].className)) {
				btns[i].className = btns[i].className.replace("acbtn-btn-choosed", "");
			}
		}
	},
	chooseAll: function(id) {
		var acBtn = this.getAcBtnById(id);
		if (bbk.isEmpty(acBtn)) {
			return;
		}
		acBtn.data = acBtn.names;
		var btns = bbk.$(id).childNodes;
		for (var i = 0; i < btns.length; i++) {
			if (!bbk.isEmpty(btns[i].className)) {
				if (btns[i].className.indexOf("acbtn-btn-choosed") < 0) {
					btns[i].className += ' acbtn-btn-choosed';
				}
			}
		}
	},
	onmouseover: function(obj) {
		obj.childNodes[1].style.display = 'block';
	},
	onmouseout: function(obj) {
		obj.childNodes[1].style.display = 'none';
	}
}


// 正则
Reg = {
	findNum: function(str) {
		let reg = new RegExp('[0-9]+');
		return str.match(reg);
	},
	findNotCn: function(str) {
		if (bbk.isEmpty(str)) {
			return '';
		}
		return str.replace(/[\u4e00-\u9fa5（）]/g, '')
	},
	isNum: function(s) {
		return /^[0-9]+$/.test(s);
	},
	hasNum: function(s) {
		return /[0-9]{1,}/.test(s);
	},
	isAllChina: function(s) {
		return /^[\u4e00-\u9fa5]+$/.test(s);
	},
	isPhone: function(p) {
		return /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(p);
	},
	isBrandId: function(s) {
		return /^[0-9]{6,8}[A]{0,1}$/.test(s);
	},
	isSexNum: function(s) {
		return /^[0-9]{6}$/.test(s);
	},
	isRealName: function(n) {
		if (!this.isAllChina(n)) {
			return false;
		}
		if (n.length < 2) {
			return false;
		}
		if (n.length > 3) {
			return false;
		}
		return true;
	},
	isColor: function(s) {
		return /^[#][0-9a-fA-F]{3,6}$/.test(s);
	},
	//商标名:中文，英文，数字，空格
	isBrandName: function(s) {
		return !/[^\u4e00-\u9fa5\w\s]/.test(s);
	}
}

var Toper = {
	toping: false, //正在移动
	obj: '',
	//size 打算移动的距离,正数向下,负数向上
	doTop: function(size) {
		let target = bbk.isEmpty(size) ? 0 : window.pageYOffset + size;
		document.body.scrollTop = document.documentElement.scrollTop = target;
		// this.toping = true;
		// clearInterval(window.timer);
		// let lastOffSet = 'false';
		// window.timer = setInterval(function() {
		// 	var step = (target - window.pageYOffset) / 10;
		// 	// step = step > 0 ? Math.ceil(step) : Math.floor(step);
		// 	if (step >-0.1 &&step<0.1 || lastOffSet == window.pageYOffset) {
		// 		Toper.toping = false;
		// 		clearInterval(window.timer);
		// 	}
		// 	lastOffSet = window.pageYOffset;
		// 	window.scroll(0, window.pageYOffset + step);
		// }, 5);
	},
	init: function() {
		this.obj = document.createElement('div');
		this.obj.className = 'toper-box';
		this.obj.innerHTML = '<i class="layui-icon layui-icon-top"></i>';
		this.obj.addEventListener('click', function() {
			Toper.doTop()
		});
		document.body.appendChild(this.obj);
		document.addEventListener('scroll', function() {
			if (window.pageYOffset >= 200) {
				Toper.obj.style.display = 'block';
			} else {
				Toper.obj.style.display = 'none';
			}
		});
	}
}

TimeUtil = {
	//是否在8:30-19:30
	isWork: function() {
		var d = new Date();
		if (d.getHours() < 8 || d.getHours() > 19) {
			return false;
		}
		if ((d.getHours() == 8 && d.getMinutes() < 30) || (d.getHours() == 19 && d.getMinutes() > 30)) {
			return false;
		}
		return true;
	}
}

Login = {
	data: {
		scanHash: '',
		isAuto: false,
		isMobile: false,
		host: location.host,
	},
	index: '',
	time: 0,
	callback: '',
	openLayer: function(title) {
		this.index = layer.open({
			skin: 'layer-login',
			title: '<div class="left" style="width:50px;height:48px"></div><div class="layer-login-title left"><i class="layui-icon layui-icon-login-wechat"></i>' +
				title + '</div>',
			type: 1,
			resize: false,
			shadeClose: true,
			content: '<div id="layer-login-qr-wrap">' +
				'<div id="login-qr-box" class="flex-center"></div>' +
				'<div class="login-text-box">' +
				'<div class="login-next-box flex-center">' +
				'<div id="login-next" onclick="Login.nextAuto(this)" class="layui-form-checkbox" lay-skin="primary">' +
				'<i class="layui-icon layui-icon-ok"></i>' +
				'</div>' +
				'<div>30天内自动登陆</div>' +
				'</div>' +
				'<div class="login-law flex-center">' +
				'登录即表示同意<a href="/pc/helper/contract/contract.html" target="_blank">《平台服务条款》</a>' +
				'</div>' +
				'</div>' +
				'</div>',
			area: ['400px', '400px'],
			cancel: function() {
				Login.time = 120;
			}
		});
	},
	show: function(title, qrUrl) {
		if (bbk.isEmpty(bbk.$('login-qr-box'))) {
			this.openLayer(title);
		}
		$('#login-qr-box').html('');
		new QRCode(bbk.$('login-qr-box'), qrUrl);
		$('#login-qr-box').attr('title', '');
		//默认勾选自动登录
		this.data.isAuto = true;
		bbk.$('login-next').className += " layui-form-checked";
	},
	nextAuto: function(obj) {
		var name = obj.className;
		if (name.indexOf("layui-form-checked") > 0) {
			obj.className = name.replace("layui-form-checked", "");
			Login.data.isAuto = false;
		} else {
			Msger.isSure("为了账户安全，请勿在他人电脑上勾选此项。", function() {
				obj.className = name + " layui-form-checked";
				Login.data.isAuto = true;
			})

		}
	},
	checkLoginHash: function() {
		let autoLoginHash = localStorage.autoLoginHash;
		if (!bbk.isEmpty(autoLoginHash)) {
			let arr = autoLoginHash.split('-');
			try {
				let timeStamp = parseInt(arr[0]);
				if (bbk.timStamp() - timeStamp < 60 * 60 * 24 * 30) {
					return true;
				}
			} catch (e) {}
		}
		return false;
	},
	login: function(onlyAuto, callback) {
		//不是静默登陆才执行
		if (!onlyAuto && layui.device().weixin) {
			WxAutoLogin.login();
			return;
		}
		this.callback = callback;
		let ajax = {
			url: '/buyer-user/auto-login',
			data: {
				autoLoginHash: localStorage.autoLoginHash,
				isMobile: layui.device().mobile
			},
			success: function(res) {
				bbk.setUser(res.data);
				switch (res.msg) {
					case Cons.MSG.SUCCESS:
						Login.success();
						return false;
					case Cons.MSG.SUCCESS_BUT_SILENGT:
						Login.success(true);
						return false;
					case Cons.MSG.FAILED:
						localStorage.autoLoginHash = '';
						if (!onlyAuto) {
							Login.scan('微信扫一扫登陆');
						}
						return false;
				}
			}
		}
		if (this.checkLoginHash()) {
			bbk.ajax(ajax);
		} else if (!onlyAuto) {
			Login.scan('微信扫一扫登陆');
		}
	},
	//from 是否是注册
	scan: function(title, callback, from, needScan, isBuyer) {
		//未传入from值
		let type = '';
		if (isBuyer) {
			type = 5;
		}
		// needScan 仅邀请链接页面使用
		if (layui.device().weixin && !needScan) {
			WxAutoLogin.login();
			return;
		}
		if (!bbk.isEmpty(callback)) {
			this.callback = callback;
		}
		if (!bbk.isEmpty($('#login-qr-box').outerHTML)) {
			//避免多个扫码窗口
			return;
		}
		let ajax = {
			url: '/buyer-user/get-login-qr',
			data: {
				host: location.host
			},
			success: function(res) {
				Login.data.scanHash = res.data.scanHash;
				Login.show(title, res.data.url);
				Login.time = 0;
				Login.polling();
			}
		}
		bbk.ajax(ajax);
	},
	success: function(isSilent) {
		if (!isSilent) {
			Msger.info('登陆成功');
		}
		if (!bbk.isEmpty(Login.callback)) {
			Login.callback();
		}
	},
	//循环访问判断是否扫码
	polling: function() {
		Login.data.isMobile = layui.device().mobile;
		let ajax = {
			url: "/buyer-user/scan-login",
			data: Login.data,
			success: function(res) {
				if (res.msg == Cons.MSG.SUCCESS) {
					layer.close(Login.index);
					Login.success();
					bbk.setUser(res.data);
					Login.time = 120;
					if (Login.data.isAuto) {
						if (layui.device().mobile) {
							localStorage.autoLoginHash = res.data.mobileLoginHash;
						} else {
							localStorage.autoLoginHash = res.data.autoLoginHash;
						}
					}
				}
				return false;
			}
		}
		bbk.ajax(ajax);
		if (Login.time < 120) {
			Login.time += 2;
			//自循环
			setTimeout(Login.polling, 2000);
		} else {
			//二维码过期
			$("#login-qr-box").html('<div onclick="Login.scan()" class="login-refresh-btn">二维码已过期,请点我刷新</div>')
		}

	}

}
var WxAutoLogin = {
	login: function() {
		localStorage.BUYER_WX_LOGIN_HREF=location.href;
		location.href =
			'https://biaobiaoku.com/html/buyer-wx-login.html?host=' + location.host;
	},
	URL_DICT: ['%', '-', '.', '_'],
	STATE_DICT: [],
	urlToState: function(url) {
		url = encodeURIComponent(url);
		let state = '';
		for (let i = 0; i < url.length; i++) {
			let dictIndex = this.URL_DICT.indexOf(url[i]);
			if (dictIndex > -1) {
				//特殊字符
				state += 'bbk' + dictIndex + 'kbb';
			} else {
				state += url[i];
			}
		}
		return state;
	},
	stateToUrl: function(state) {
		let reg = new RegExp('bbk[0-9]{1,2}kbb', 'g');
		let arr = state.match(reg);
		for (let i = 0; i < arr.length; i++) {
			let dictIndex = arr[i].replace('bbk', '').replace('kbb', '');
			dictIndex = parseInt(dictIndex);
			state = state.replace(arr[i], this.URL_DICT[dictIndex]);
		}
		return decodeURIComponent(state);
	}


}
Nav = {
	init: function() {
		let hoster = Hoster.getHoster();
		let hideKit;
		if(bbk.isEmpty(hoster)){
			hideKit='style="display:none;"';
		}else{
			hideKit=hoster.showCuber?'':'style="display:none;"';
		}
		let closeBtn = layui.device().mobile ?
			'<a id="close-btn-a" class="nav-btn-item2" href="javascript:Nav.close()""><i id="nav-close-i" class="layui-icon layui-icon-up"></i><br>隐藏</a>' :
			'';
		let index, teamer, myBrander, kit, me, saver = '';
		let url = location.href;
		Cons.baseColor = bbk.isEmpty(hoster.baseColor) ? Cons.baseColor : hoster.baseColor;
		if (location.pathname.length < 2 && bbk.isEmpty(bbk.getUrlVal('page'))) {
			index = Cons.baseColor + ";color:#fff";
		}  else if (url.indexOf('kit') > -1) {
			kit = Cons.baseColor + ";color:#fff";
		} else if (url.indexOf('me') > -1) {
			me = Cons.baseColor + ";color:#fff";
		} else if (url.indexOf('saver') > -1) {
			saver = Cons.baseColor + ";color:#fff";
		}
		let isHide = (bbk.isBuyer() || bbk.isAgenter()) ? 'style="display:none"' : '';
		let html =
			各规格;
		$('.base-nav-box').remove();
		$('body').append(html);
		let old;
		$('.nav-btn-item').mouseover(function(obj) {
			old = $(this).css('background-color');
			console.info(old);
			$(this).css('background-color', Cons.baseColor).css('color', '#fff');
		})
		$('.nav-btn-item').mouseout(function(obj) {
			if (old == 'rgb(243, 243, 243)') {
				$(this).css('background-color', '#f3f3f3').css('color', '#666');
			}
		})

	},
	close: function() {
		console.info(1)
		if ($('#nav-btn-box').css('display') == 'none') {
			$('#nav-btn-box').css('display', 'inline-block');
			$('#close-btn-a').html($('#close-btn-a').html().replace('展开', '隐藏'));
			bbk.$('nav-close-i').className = bbk.$('nav-close-i').className.replace('layui-icon-down',
				'layui-icon-up');
		} else {
			$('#nav-btn-box').css('display', 'none');
			$('#close-btn-a').html($('#close-btn-a').html().replace('隐藏', '展开'));
			bbk.$('nav-close-i').className = bbk.$('nav-close-i').className.replace('layui-icon-up',
				'layui-icon-down')
		}
	}

}

Imger = {
	showBigError: function(obj) {
		obj.src = 'https://bbk-public-filer-1258286853.cos.ap-shanghai.myqcloud.com/model/error-big.png'
	},
	bigger: function(url) {
		layer.open({
			skin: 'layer-imger',
			title: '图片',
			type: 1,
			resize: true,
			content: '<img src="' + url + '" onerror="Imger.showBigError(this)"/>',
			area: ['510px', '510px'],
		});
	},
	biggerSrc: function(obj) {
		this.bigger(obj.src);
	},
	//type 可选值 raw:0,small:1,color:2
	getUrl: function(item, type) {
		if (bbk.isEmpty(item.picHash)) {
			return '';
		}
		//没有彩图
		if (0 == item.picColor) {
			return Cons.PRE_URL.CDN_RAW + item.brandId + "-" + item.picHash + ".jpg";
		}
		//type是期望的type,没有自动使用原图
		switch (type) {
			case Cons.IMAGE_TYPE.RAW:
				return Cons.PRE_URL.CDN_RAW + item.brandId + "-" + item.picHash + ".jpg";
			case Cons.IMAGE_TYPE.COLOR_250:
				return Cons.PRE_URL.CDN_COLLOR + item.brandId + "-" + item.picHash + "-250.png";
			default:
				console.error("无法识别该type:" + type);
				return Cons.PRE_URL.CDN_RAW + item.brandId + "-" + item.picHash + ".jpg";
		}

	},
	getCosUrl: function(item, type) {
		if (bbk.isEmpty(item.picHash)) {
			return '';
		}
		//没有彩图
		if (0 == item.picColor) {
			return Cons.PRE_URL.BRAND_PICER + item.brandId + "-" + item.picHash + ".jpg";
		}
		//type是期望的type,没有自动使用原图
		switch (type) {
			case Cons.IMAGE_TYPE.RAW:
				return Cons.PRE_URL.BRAND_PICER + item.brandId + "-" + item.picHash + ".jpg";
			case Cons.IMAGE_TYPE.COLOR_250:
				return Cons.PRE_URL.COLOR_PICER + item.brandId + "-" + item.picHash + "-250.png";
			default:
				console.error("无法识别该type:" + type);
				return Cons.PRE_URL.BRAND_PICER + item.brandId + "-" + item.picHash + ".jpg";
		}
	}
}

Tiper = {
	doClickName: function() {
		localStorage.TIPER_HAVE_CLICKED_NAME = 1;
	},
	haveClicedName: function() {
		return !bbk.isEmpty(localStorage.TIPER_HAVE_CLICKED_NAME);
	},
	doClickSafe: function() {
		localStorage.TIPER_HAVE_CLICED_SAFE = 1;
		$('.tiper-safe').css('display', 'none');
	},
	initSafe: function() {
		if (bbk.isEmpty(localStorage.TIPER_HAVE_CLICED_SAFE)) {
			$('.tiper-safe').css('display', 'block');
		}
	}
}

Logo = {
	init: function(el) {
		let html = '<div class="logo-out-box logo-color-body">' +
			'<div class="logo-face logo-color-eye">' +
			'<div class="logo-up-arc">' +
			'<div class="logo-bottom-arc logo-color-body">' +
			'</div>' +
			'</div>' +
			'</div>' +
			'<div class="logo-eye-box logo-color-body">' +
			'<div class="logo-left-eye logo-eye logo-color-eye"></div>' +
			'<div class="logo-right-eye logo-eye logo-color-eye"></div>' +
			'</div></div>';
		$(el).html(html);
	},
	setColor: function(color) {
		$('.logo-color-body').css('background', color);
		$('.logo-box').css('background', color);
		$('.logo-inner-middle-circle').css('background', color);
		$('.logo-eye-box').css('background', color);
	},
	jump: function(el) {
		$(el).find('.logo-eye').addClass('ani-jump');
	},
	stop: function(el) {
		$(el).find('.logo-eye').removeClass('ani-jump');
	}
}

var ColorBox = {
	render: function(callback) {
		let html =
			'<div class="base-color-box hidden" >' +
			'<li @click="click(color)" v-for="color in colors" :style="{background:color}"></li>' +
			'</div>' +
			'<div class="base-color-input-box">' +
			'颜色值:<input id="base-color-box-input" placeholder="如:#ff0000"></input>' +
			'</div>';
		Msger.isSure(html, function() {
			let color = bbk.getVal('base-color-box-input');
			if (!bbk.isEmpty(color)) {
				if (!Reg.isColor(color)) {
					Msger.info('不正确的颜色值,请重新输入');
					return;
				}
				callback(color);
			}
		});
		let colors = [];
		for (let r = 0; r < 256; r += 35) {
			for (let g = 0; g < 256; g += 35) {
				for (let b = 0; b < 256; b += 35) {
					let color = '#' + bbk.getTwo2(r.toString(16)) + bbk.getTwo2(g.toString(16)) + bbk.getTwo2(b
						.toString(16));
					colors.push(color);
				}
			}
		}
		let vue = {
			el: '.base-color-box',
			data: {
				colors: colors
			},
			methods: {
				click: function(color) {
					$('.layui-layer-dialog').css('background', color);
					$('#base-color-box-input').val(color);
					$('.layui-layer-shade').css('opacity', '0.3');
				}
			}
		}

		new Vue(vue);
	}
}

var Inputer = {
	data: [],
	getBranders: function(el) {
		let content = $(el).val();
		content = bbk.trim(content);
		return this.getBrandersByStr(content);
	},
	getBrandersByStr: function(content) {
		let arr = content.split('\n');
		let branders = [];
		for (let i = 0; i < arr.length; i++) {
			let one = arr[i];
			if (!bbk.isEmpty(one)) {
				b = this.getBrander(one);
				if (bbk.isEmpty(b)) {
					Msger.talk('无法识别该行的商标号:' + one)
					return;
				}
				branders.push(b);
			}
		}
		return branders;
	},
	//每行数据解析成对象
	getBrander: function(one) {
		let reg = new RegExp('[0-9]{6,8}[A]{0,1}');
		let b = {};
		let arr = one.match(reg);
		if (bbk.isEmpty(arr)) {
			return;
		}
		b.brandId = one.match(reg)[0];
		b.price = bbk.trim(one.replace(new RegExp(b.brandId, 'g'), ''));
		if (bbk.isEmpty(b.brandId)) {
			return;
		}
		if (bbk.isEmpty(b.price)) {
			return b;
		}
		b.price = bbk.getPrice(b.price);
		return b;
	}
}

//提示
var InputTiper = {
	tipers: [],
	getTiperById: function(id) {
		for (let i = 0; i < this.tipers.length; i++) {
			if (tipers[i].id == id) {
				console.info('from cache');
				return tipers[i];
			}
		}
	},
	show: function(id) {
		console.info("show:" + id);
		if (bbk.isEmpty(bbk.$('input-tiper-' + id))) {
			let box = document.createElement('div');
			box.id = 'input-tiper-' + id;
			box.className = 'bbk-input-tiper';
			box.style.width = bbk.$(id).clientWidth + 'px';
			box.innerHTML = "11111111111111";
			bbk.$(id).parentElement.append(box);

			console.info(bbk.$(id).clientWidth);
		}
	},
	hidden: function(id) {

	},
	onkeyup: function(id) {

	},
	//json{id:'',onkeyup:func}
	init: function(tiper) {
		console.info(tiper);
		this.tipers.push(tiper);
		bbk.$(tiper.id).addEventListener('focus', function() {
			InputTiper.show(this.id);
		})
		bbk.$(tiper.id).addEventListener('blur', function() {
			InputTiper.hidden(this.id);
		})
		bbk.$(tiper.id).addEventListener('keyup', function() {
			InputTiper.onkeyup(this.id);
		})
	}
}

var ImagerChanger = {
	isPng: '',
	//缓存
	data: [], //{imgUrl:'',color:'',imgData:''}
	isGrey: function(data, i) {
		if (Math.abs(data[i - 3] - data[i - 2]) > 20) {
			return false;
		}
		if (Math.abs(data[i - 3] - data[i - 1]) > 20) {
			return false;
		}
		return true;
	},
	getAlp: function(data, i) {
		if (this.isPng) {
			if (data[i] < 255) {
				return data[i];
			} else {
				if (!this.isGrey(data, i)) {
					return data[i];
				}
			}
		}
		return parseInt(255 - (data[i - 3] + data[i - 2] + data[i - 1]) / 3);
	},
	//eg:color='#ff00ff',imgUrl主要用于缓存搜索
	randerImageData: function(obj, color, addAlp) {
		if (bbk.isEmpty(obj)) {
			console.warn('obj is null');
			return;
		}
		let imgSrc = obj.src;
		let img = new Image();
		this.isPng = imgSrc.indexOf('.png') > -1 || imgSrc.indexOf('data:image/png;base64') > -1 ? true : false;
		img.src = imgSrc;
		img.crossOrigin = 'anonymous';
		let newR;
		let newG;
		let newB;
		if (!bbk.isEmpty(color)) {
			newR = parseInt("0x" + color.substr(1, 2));
			newG = parseInt("0x" + color.substr(3, 2));
			newB = parseInt("0x" + color.substr(5, 2));
		}
		//图片加载后进行处理
		img.onload = function() {
			let width = img.width,
				height = img.height,
				canvas = document.createElement("canvas"),
				ctx = canvas.getContext("2d");
			canvas.width = width;
			canvas.height = height;
			// 将源图片复制到画布上
			ctx.drawImage(img, 0, 0, width, height);
			// 获取画布的像素信息
			let metaData = ctx.getImageData(0, 0, width, height),
				data = metaData.data;
			// 对像素集合中的单个像素进行循环，每个像素是由4个通道组成，所以要注意
			let i = 0;
			while (i < data.length) {
				let alp = ImagerChanger.getAlp(data, (i + 3));
				if (alp == 0) {
					alp = 0;
				} else {
					alp = alp + addAlp > 255 ? 255 : alp + addAlp;
				}

				//先定透明度
				data[i + 3] = alp;
				if (!bbk.isEmpty(color)) {
					data[i] = newR;
					data[i + 1] = newG;
					data[i + 2] = newB;
				}
				i += 4;
			}
			// 将修改后的代码复制回画布中
			ctx.putImageData(metaData, 0, 0);
			// 图片导出为 png 格式
			let imgType = "png";
			let imgData = canvas.toDataURL(imgType);
			obj.src = imgData + '';
		};
	},
}


//支付模块
var Payer = {
	callback: '', //成功付款后的回调
	data: '',
	id: '', //PayOrder的id
	polling: false,
	times: 0,
	//点击续费按钮 data={cny:0.99,name:'12345678-更多联系人'}
	init: function(callback, data) {
		this.callback = callback;
		this.data = data;
		this.showQr();
		this.create();
		this.polling = true;
		Payer.times = 0;
		this.check();
	},
	showQr: function() {
		//显示二维码
		var layer = layui.layer;
		let content = '<div class="pay-box">' +
			'<div class="pay-title"><i class="layui-icon layui-icon-login-wechat icon-wx"></i>&nbsp;微信支付 ￥:' +
			Payer.data.cny / 100 + '</div>' +
			'<div class="pay-qr-box"><div class="qr-img-box"><i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i></div><div class="pay-tip">微信扫一扫支付</div></div>' +
			'</div>';
		let index = layer.open({
			skin: 'file-bigger', //?
			title: Payer.data.name,
			area: ['450px', '520px'],
			type: 1,
			content: content,
			cancel: function(index, layero) {
				Payer.polling = false;
			}
		});
		//轮询确实是否已支付
	},
	create: function() {
		let ajax = {
			url: '/pay-order/create',
			data: Payer.data,
			success: function(res) {
				console.info(res);
				$(".qr-img-box").html('<img src="' + bbk.getQrSrc(res.data.url) + '"></img>')
				Payer.id = res.data.id;
				return false;
			},
		}
		bbk.ajax(ajax);
	},
	check: function() {
		var ajax = {
			url: "/pay-order/check",
			data: {
				id: Payer.id
			},
			success: function(res) {
				if (res.msg == "SUCCESS") {
					console.info(res);
					layui.layer.close(layui.layer.index);
					if (!bbk.isEmpty(Payer.callback)) {
						//回调参数是 payOrder对象
						Payer.callback(res.data);
					}
					Payer.polling = false;
				}
				return false;
			}
		}
		if (Payer.polling) {
			if (Payer.times < 600) {
				Payer.times += 2;
				if (!bbk.isEmpty(Payer.id)) {
					bbk.ajax(ajax);
				}
				setTimeout(Payer.check, 2000);
			} else {
				layui.layer.close(layui.layer.index);
				Msger.talk('超过10分钟未支付');
			}
		}
	}
}
